package com.yaoming.umengshare;

import android.app.Activity;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.yaoming.umengshare.R;
import com.yaoming.umengshare.listener.UmShareBoardlistener;

/**
 * Created by zwj on 2015/12/24.
 */
public class MainActivity extends Activity implements View.OnClickListener{
    private TextView tv;
    private TextView tv2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv=(TextView)findViewById(R.id.tv);
        tv2=(TextView)findViewById(R.id.tv2);
        tv.setOnClickListener(this);
        tv2.setOnClickListener(this);
        init();
    }
    public void init(){
        PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
        //微信 appid appsecret
        PlatformConfig.setSinaWeibo("3921700954","04b48b094faeb16683c32669824ebdad","http://sns.whalecloud.com/sina2/callback");
        //新浪微博 appkey appsecret
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
        // QQ和Qzone appid appkey
        PlatformConfig.setAlipay("2015111700822536");
        //支付宝 appid

    }
    @Override
    public void onClick(View v) {
        switch (v.getId() ) {
//            case R.id.tv:
//                Intent intent=new Intent(this,UmShareActivity.class);
//                startActivity(intent);
//                break;
//            case R.id.tv2:
//                showShare();
//                break;
        }

//        showShare();
    }

    final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]
            {
                    SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE,SHARE_MEDIA.SINA,
                    SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE,SHARE_MEDIA.EMAIL,SHARE_MEDIA.SMS
                    ,SHARE_MEDIA.TENCENT
            };


    ShareAction shareAction;
    public void showShare(){

        //ShareAction action=new ShareAction(this);
        new ShareAction(this).setDisplayList( displaylist )
                .withText( "我来试试" )
                .withMedia(new UMImage(this, BitmapFactory.decodeResource(getResources(),R.drawable.umeng_socialize_wechat)))
//                .setShareboardclickCallback(new UmShareBoardlistener(this))
                .setCallback(new UMShareListener() {
                    @Override
                    public void onStart(SHARE_MEDIA share_media) {
                        
                    }

                    @Override
                    public void onResult(SHARE_MEDIA share_media) {

                    }

                    @Override
                    public void onError(SHARE_MEDIA share_media, Throwable throwable) {

                    }

                    @Override
                    public void onCancel(SHARE_MEDIA share_media) {
                        MainActivity.this.finish();
                    }
                })
                .open();
    }
}
